package com.schoolCommunity.util;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Component;

import java.util.concurrent.TimeUnit;

@Component
public class RedisUtil {

    @Autowired
    @Qualifier("MyTemplate")
    private RedisTemplate redisTemplate;

    //判断key是否存在redis
    public boolean CheckRedis(String redisKey) {
        return redisTemplate.hasKey(redisKey);
    }

    //写入redis点赞的keys
    public void InsertRedis(String key, String value) {
        //保存一天
        redisTemplate.opsForValue().set(key, value, 1, TimeUnit.DAYS);
    }

}
